\(\int \tan ^2(e+f x) (a+b \tan ^2(e+f x))^2 \, dx\) [206]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 23, antiderivative size = 69 \[ \int \tan ^2(e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=-(a-b)^2 x+\frac {(a-b)^2 \tan (e+f x)}{f}+\frac {(2 a-b) b \tan ^3(e+f x)}{3 f}+\frac {b^2 \tan ^5(e+f x)}{5 f} \]

[Out]

-(a-b)^2*x+(a-b)^2*tan(f*x+e)/f+1/3*(2*a-b)*b*tan(f*x+e)^3/f+1/5*b^2*tan(f*x+e)^5/f

Rubi [A] (verified)

Time = 0.09 (sec) , antiderivative size = 69, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.130, Rules used = {3751, 472, 209} \[ \int \tan ^2(e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=\frac {b (2 a-b) \tan ^3(e+f x)}{3 f}+\frac {(a-b)^2 \tan (e+f x)}{f}-x (a-b)^2+\frac {b^2 \tan ^5(e+f x)}{5 f} \]

[In]

Int[Tan[e + f*x]^2*(a + b*Tan[e + f*x]^2)^2,x]

[Out]

-((a - b)^2*x) + ((a - b)^2*Tan[e + f*x])/f + ((2*a - b)*b*Tan[e + f*x]^3)/(3*f) + (b^2*Tan[e + f*x]^5)/(5*f)

Rule 209

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[b, 2]))*ArcTan[Rt[b, 2]*(x/Rt[a, 2])], x] /;
 FreeQ[{a, b}, x] && PosQ[a/b] && (GtQ[a, 0] || GtQ[b, 0])

Rule 472

Int[(((e_.)*(x_))^(m_.)*((a_) + (b_.)*(x_)^(n_))^(p_))/((c_) + (d_.)*(x_)^(n_)), x_Symbol] :> Int[ExpandIntegr
and[(e*x)^m*((a + b*x^n)^p/(c + d*x^n)), x], x] /; FreeQ[{a, b, c, d, e, m}, x] && NeQ[b*c - a*d, 0] && IGtQ[n
, 0] && IGtQ[p, 0] && (IntegerQ[m] || IGtQ[2*(m + 1), 0] ||  !RationalQ[m])

Rule 3751

Int[((d_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((a_) + (b_.)*((c_.)*tan[(e_.) + (f_.)*(x_)])^(n_))^(p_.), x_Symbol]
 :> With[{ff = FreeFactors[Tan[e + f*x], x]}, Dist[c*(ff/f), Subst[Int[(d*ff*(x/c))^m*((a + b*(ff*x)^n)^p/(c^2
 + ff^2*x^2)), x], x, c*(Tan[e + f*x]/ff)], x]] /; FreeQ[{a, b, c, d, e, f, m, n, p}, x] && (IGtQ[p, 0] || EqQ
[n, 2] || EqQ[n, 4] || (IntegerQ[p] && RationalQ[n]))

Rubi steps \begin{align*} \text {integral}& = \frac {\text {Subst}\left (\int \frac {x^2 \left (a+b x^2\right )^2}{1+x^2} \, dx,x,\tan (e+f x)\right )}{f} \\ & = \frac {\text {Subst}\left (\int \left ((a-b)^2+(2 a-b) b x^2+b^2 x^4+\frac {-a^2+2 a b-b^2}{1+x^2}\right ) \, dx,x,\tan (e+f x)\right )}{f} \\ & = \frac {(a-b)^2 \tan (e+f x)}{f}+\frac {(2 a-b) b \tan ^3(e+f x)}{3 f}+\frac {b^2 \tan ^5(e+f x)}{5 f}-\frac {(a-b)^2 \text {Subst}\left (\int \frac {1}{1+x^2} \, dx,x,\tan (e+f x)\right )}{f} \\ & = -(a-b)^2 x+\frac {(a-b)^2 \tan (e+f x)}{f}+\frac {(2 a-b) b \tan ^3(e+f x)}{3 f}+\frac {b^2 \tan ^5(e+f x)}{5 f} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.06 (sec) , antiderivative size = 137, normalized size of antiderivative = 1.99 \[ \int \tan ^2(e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=-\frac {a^2 \arctan (\tan (e+f x))}{f}+\frac {2 a b \arctan (\tan (e+f x))}{f}-\frac {b^2 \arctan (\tan (e+f x))}{f}+\frac {a^2 \tan (e+f x)}{f}-\frac {2 a b \tan (e+f x)}{f}+\frac {b^2 \tan (e+f x)}{f}+\frac {2 a b \tan ^3(e+f x)}{3 f}-\frac {b^2 \tan ^3(e+f x)}{3 f}+\frac {b^2 \tan ^5(e+f x)}{5 f} \]

[In]

Integrate[Tan[e + f*x]^2*(a + b*Tan[e + f*x]^2)^2,x]

[Out]

-((a^2*ArcTan[Tan[e + f*x]])/f) + (2*a*b*ArcTan[Tan[e + f*x]])/f - (b^2*ArcTan[Tan[e + f*x]])/f + (a^2*Tan[e +
 f*x])/f - (2*a*b*Tan[e + f*x])/f + (b^2*Tan[e + f*x])/f + (2*a*b*Tan[e + f*x]^3)/(3*f) - (b^2*Tan[e + f*x]^3)
/(3*f) + (b^2*Tan[e + f*x]^5)/(5*f)

Maple [A] (verified)

Time = 0.06 (sec) , antiderivative size = 77, normalized size of antiderivative = 1.12

method result size
norman \(\left (-a^{2}+2 a b -b^{2}\right ) x +\frac {\left (a^{2}-2 a b +b^{2}\right ) \tan \left (f x +e \right )}{f}+\frac {b^{2} \tan \left (f x +e \right )^{5}}{5 f}+\frac {\left (2 a -b \right ) b \tan \left (f x +e \right )^{3}}{3 f}\) \(77\)
derivativedivides \(\frac {\frac {b^{2} \tan \left (f x +e \right )^{5}}{5}+\frac {2 a b \tan \left (f x +e \right )^{3}}{3}-\frac {b^{2} \tan \left (f x +e \right )^{3}}{3}+a^{2} \tan \left (f x +e \right )-2 a b \tan \left (f x +e \right )+b^{2} \tan \left (f x +e \right )+\left (-a^{2}+2 a b -b^{2}\right ) \arctan \left (\tan \left (f x +e \right )\right )}{f}\) \(97\)
default \(\frac {\frac {b^{2} \tan \left (f x +e \right )^{5}}{5}+\frac {2 a b \tan \left (f x +e \right )^{3}}{3}-\frac {b^{2} \tan \left (f x +e \right )^{3}}{3}+a^{2} \tan \left (f x +e \right )-2 a b \tan \left (f x +e \right )+b^{2} \tan \left (f x +e \right )+\left (-a^{2}+2 a b -b^{2}\right ) \arctan \left (\tan \left (f x +e \right )\right )}{f}\) \(97\)
parallelrisch \(-\frac {-3 b^{2} \tan \left (f x +e \right )^{5}-10 a b \tan \left (f x +e \right )^{3}+5 b^{2} \tan \left (f x +e \right )^{3}+15 a^{2} f x -30 a b f x +15 b^{2} f x -15 a^{2} \tan \left (f x +e \right )+30 a b \tan \left (f x +e \right )-15 b^{2} \tan \left (f x +e \right )}{15 f}\) \(97\)
parts \(\frac {a^{2} \left (\tan \left (f x +e \right )-\arctan \left (\tan \left (f x +e \right )\right )\right )}{f}+\frac {b^{2} \left (\frac {\tan \left (f x +e \right )^{5}}{5}-\frac {\tan \left (f x +e \right )^{3}}{3}+\tan \left (f x +e \right )-\arctan \left (\tan \left (f x +e \right )\right )\right )}{f}+\frac {2 a b \left (\frac {\tan \left (f x +e \right )^{3}}{3}-\tan \left (f x +e \right )+\arctan \left (\tan \left (f x +e \right )\right )\right )}{f}\) \(101\)
risch \(-x \,a^{2}+2 x a b -x \,b^{2}+\frac {2 i \left (15 a^{2} {\mathrm e}^{8 i \left (f x +e \right )}-60 a b \,{\mathrm e}^{8 i \left (f x +e \right )}+45 b^{2} {\mathrm e}^{8 i \left (f x +e \right )}+60 a^{2} {\mathrm e}^{6 i \left (f x +e \right )}-180 a b \,{\mathrm e}^{6 i \left (f x +e \right )}+90 b^{2} {\mathrm e}^{6 i \left (f x +e \right )}+90 a^{2} {\mathrm e}^{4 i \left (f x +e \right )}-220 a b \,{\mathrm e}^{4 i \left (f x +e \right )}+140 b^{2} {\mathrm e}^{4 i \left (f x +e \right )}+60 a^{2} {\mathrm e}^{2 i \left (f x +e \right )}-140 a b \,{\mathrm e}^{2 i \left (f x +e \right )}+70 b^{2} {\mathrm e}^{2 i \left (f x +e \right )}+15 a^{2}-40 a b +23 b^{2}\right )}{15 f \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right )^{5}}\) \(217\)

[In]

int(tan(f*x+e)^2*(a+b*tan(f*x+e)^2)^2,x,method=_RETURNVERBOSE)

[Out]

(-a^2+2*a*b-b^2)*x+(a^2-2*a*b+b^2)/f*tan(f*x+e)+1/5*b^2*tan(f*x+e)^5/f+1/3*(2*a-b)*b*tan(f*x+e)^3/f

Fricas [A] (verification not implemented)

none

Time = 0.27 (sec) , antiderivative size = 73, normalized size of antiderivative = 1.06 \[ \int \tan ^2(e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=\frac {3 \, b^{2} \tan \left (f x + e\right )^{5} + 5 \, {\left (2 \, a b - b^{2}\right )} \tan \left (f x + e\right )^{3} - 15 \, {\left (a^{2} - 2 \, a b + b^{2}\right )} f x + 15 \, {\left (a^{2} - 2 \, a b + b^{2}\right )} \tan \left (f x + e\right )}{15 \, f} \]

[In]

integrate(tan(f*x+e)^2*(a+b*tan(f*x+e)^2)^2,x, algorithm="fricas")

[Out]

1/15*(3*b^2*tan(f*x + e)^5 + 5*(2*a*b - b^2)*tan(f*x + e)^3 - 15*(a^2 - 2*a*b + b^2)*f*x + 15*(a^2 - 2*a*b + b
^2)*tan(f*x + e))/f

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 117 vs. \(2 (54) = 108\).

Time = 0.15 (sec) , antiderivative size = 117, normalized size of antiderivative = 1.70 \[ \int \tan ^2(e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=\begin {cases} - a^{2} x + \frac {a^{2} \tan {\left (e + f x \right )}}{f} + 2 a b x + \frac {2 a b \tan ^{3}{\left (e + f x \right )}}{3 f} - \frac {2 a b \tan {\left (e + f x \right )}}{f} - b^{2} x + \frac {b^{2} \tan ^{5}{\left (e + f x \right )}}{5 f} - \frac {b^{2} \tan ^{3}{\left (e + f x \right )}}{3 f} + \frac {b^{2} \tan {\left (e + f x \right )}}{f} & \text {for}\: f \neq 0 \\x \left (a + b \tan ^{2}{\left (e \right )}\right )^{2} \tan ^{2}{\left (e \right )} & \text {otherwise} \end {cases} \]

[In]

integrate(tan(f*x+e)**2*(a+b*tan(f*x+e)**2)**2,x)

[Out]

Piecewise((-a**2*x + a**2*tan(e + f*x)/f + 2*a*b*x + 2*a*b*tan(e + f*x)**3/(3*f) - 2*a*b*tan(e + f*x)/f - b**2
*x + b**2*tan(e + f*x)**5/(5*f) - b**2*tan(e + f*x)**3/(3*f) + b**2*tan(e + f*x)/f, Ne(f, 0)), (x*(a + b*tan(e
)**2)**2*tan(e)**2, True))

Maxima [A] (verification not implemented)

none

Time = 0.32 (sec) , antiderivative size = 76, normalized size of antiderivative = 1.10 \[ \int \tan ^2(e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=\frac {3 \, b^{2} \tan \left (f x + e\right )^{5} + 5 \, {\left (2 \, a b - b^{2}\right )} \tan \left (f x + e\right )^{3} - 15 \, {\left (a^{2} - 2 \, a b + b^{2}\right )} {\left (f x + e\right )} + 15 \, {\left (a^{2} - 2 \, a b + b^{2}\right )} \tan \left (f x + e\right )}{15 \, f} \]

[In]

integrate(tan(f*x+e)^2*(a+b*tan(f*x+e)^2)^2,x, algorithm="maxima")

[Out]

1/15*(3*b^2*tan(f*x + e)^5 + 5*(2*a*b - b^2)*tan(f*x + e)^3 - 15*(a^2 - 2*a*b + b^2)*(f*x + e) + 15*(a^2 - 2*a
*b + b^2)*tan(f*x + e))/f

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 879 vs. \(2 (65) = 130\).

Time = 1.13 (sec) , antiderivative size = 879, normalized size of antiderivative = 12.74 \[ \int \tan ^2(e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=\text {Too large to display} \]

[In]

integrate(tan(f*x+e)^2*(a+b*tan(f*x+e)^2)^2,x, algorithm="giac")

[Out]

-1/15*(15*a^2*f*x*tan(f*x)^5*tan(e)^5 - 30*a*b*f*x*tan(f*x)^5*tan(e)^5 + 15*b^2*f*x*tan(f*x)^5*tan(e)^5 - 75*a
^2*f*x*tan(f*x)^4*tan(e)^4 + 150*a*b*f*x*tan(f*x)^4*tan(e)^4 - 75*b^2*f*x*tan(f*x)^4*tan(e)^4 + 15*a^2*tan(f*x
)^5*tan(e)^4 - 30*a*b*tan(f*x)^5*tan(e)^4 + 15*b^2*tan(f*x)^5*tan(e)^4 + 15*a^2*tan(f*x)^4*tan(e)^5 - 30*a*b*t
an(f*x)^4*tan(e)^5 + 15*b^2*tan(f*x)^4*tan(e)^5 + 150*a^2*f*x*tan(f*x)^3*tan(e)^3 - 300*a*b*f*x*tan(f*x)^3*tan
(e)^3 + 150*b^2*f*x*tan(f*x)^3*tan(e)^3 + 10*a*b*tan(f*x)^5*tan(e)^2 - 5*b^2*tan(f*x)^5*tan(e)^2 - 60*a^2*tan(
f*x)^4*tan(e)^3 + 150*a*b*tan(f*x)^4*tan(e)^3 - 75*b^2*tan(f*x)^4*tan(e)^3 - 60*a^2*tan(f*x)^3*tan(e)^4 + 150*
a*b*tan(f*x)^3*tan(e)^4 - 75*b^2*tan(f*x)^3*tan(e)^4 + 10*a*b*tan(f*x)^2*tan(e)^5 - 5*b^2*tan(f*x)^2*tan(e)^5
- 150*a^2*f*x*tan(f*x)^2*tan(e)^2 + 300*a*b*f*x*tan(f*x)^2*tan(e)^2 - 150*b^2*f*x*tan(f*x)^2*tan(e)^2 + 3*b^2*
tan(f*x)^5 - 20*a*b*tan(f*x)^4*tan(e) + 25*b^2*tan(f*x)^4*tan(e) + 90*a^2*tan(f*x)^3*tan(e)^2 - 240*a*b*tan(f*
x)^3*tan(e)^2 + 150*b^2*tan(f*x)^3*tan(e)^2 + 90*a^2*tan(f*x)^2*tan(e)^3 - 240*a*b*tan(f*x)^2*tan(e)^3 + 150*b
^2*tan(f*x)^2*tan(e)^3 - 20*a*b*tan(f*x)*tan(e)^4 + 25*b^2*tan(f*x)*tan(e)^4 + 3*b^2*tan(e)^5 + 75*a^2*f*x*tan
(f*x)*tan(e) - 150*a*b*f*x*tan(f*x)*tan(e) + 75*b^2*f*x*tan(f*x)*tan(e) + 10*a*b*tan(f*x)^3 - 5*b^2*tan(f*x)^3
 - 60*a^2*tan(f*x)^2*tan(e) + 150*a*b*tan(f*x)^2*tan(e) - 75*b^2*tan(f*x)^2*tan(e) - 60*a^2*tan(f*x)*tan(e)^2
+ 150*a*b*tan(f*x)*tan(e)^2 - 75*b^2*tan(f*x)*tan(e)^2 + 10*a*b*tan(e)^3 - 5*b^2*tan(e)^3 - 15*a^2*f*x + 30*a*
b*f*x - 15*b^2*f*x + 15*a^2*tan(f*x) - 30*a*b*tan(f*x) + 15*b^2*tan(f*x) + 15*a^2*tan(e) - 30*a*b*tan(e) + 15*
b^2*tan(e))/(f*tan(f*x)^5*tan(e)^5 - 5*f*tan(f*x)^4*tan(e)^4 + 10*f*tan(f*x)^3*tan(e)^3 - 10*f*tan(f*x)^2*tan(
e)^2 + 5*f*tan(f*x)*tan(e) - f)

Mupad [B] (verification not implemented)

Time = 11.89 (sec) , antiderivative size = 100, normalized size of antiderivative = 1.45 \[ \int \tan ^2(e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=\frac {{\mathrm {tan}\left (e+f\,x\right )}^3\,\left (\frac {2\,a\,b}{3}-\frac {b^2}{3}\right )}{f}-\frac {\mathrm {atan}\left (\frac {\mathrm {tan}\left (e+f\,x\right )\,{\left (a-b\right )}^2}{a^2-2\,a\,b+b^2}\right )\,{\left (a-b\right )}^2}{f}+\frac {\mathrm {tan}\left (e+f\,x\right )\,\left (a^2-2\,a\,b+b^2\right )}{f}+\frac {b^2\,{\mathrm {tan}\left (e+f\,x\right )}^5}{5\,f} \]

[In]

int(tan(e + f*x)^2*(a + b*tan(e + f*x)^2)^2,x)

[Out]

(tan(e + f*x)^3*((2*a*b)/3 - b^2/3))/f - (atan((tan(e + f*x)*(a - b)^2)/(a^2 - 2*a*b + b^2))*(a - b)^2)/f + (t
an(e + f*x)*(a^2 - 2*a*b + b^2))/f + (b^2*tan(e + f*x)^5)/(5*f)